import 'package:flutter/material.dart';
import 'package:wechat_demo/Scenes/AddressBook/addressbook_page.dart';
import 'package:wechat_demo/Scenes/Chat/chat_page.dart';
import 'package:wechat_demo/Scenes/Discover/discover_page.dart';
import 'package:wechat_demo/Scenes/Mine/mine_page.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final _selectColor = Colors.green;
  final double _selectFontSize = 12;
  final List<Widget> _pages = const [
    ChatPage(),
    AddressBookPage(),
    DiscoverPage(),
    MinePage(),
  ];
  int _currentIndex = 2;

  _changePage(int page) {
    setState(() {
      _currentIndex = page;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: BottomNavigationBar(
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.chat), label: "微信"),
          BottomNavigationBarItem(icon: Icon(Icons.book), label: "通讯录"),
          BottomNavigationBarItem(icon: Icon(Icons.find_in_page), label: "发现"),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: "我"),
        ],
        type: BottomNavigationBarType.fixed,
        fixedColor: _selectColor,
        selectedFontSize: _selectFontSize,
        currentIndex: _currentIndex,
        onTap: _changePage,
      ),
      body: _pages[_currentIndex],
    );
  }
}
